package lex.dm.ui.dbtree;

import javax.swing.tree.DefaultMutableTreeNode;

public class DBNode extends DefaultMutableTreeNode {
	public static final int CATALOG_NODE = 0;
	public static final int TABLE_NODE = 1;
	public static final int FIELD_NODE = 2;
	public static final int TYPE_NODE = 3;
	private final int nodeType;

	public static DBNode newRootNode(String name) {
		return new DBNode(CATALOG_NODE, name, true);
	}

	public static DBNode newTableNode(String name) {
		return new DBNode(TABLE_NODE, name, true);
	}

	public static DBNode newFieldNode(String name) {
		return new DBNode(FIELD_NODE, name, true);
	}

	public static DBNode newTypeNode(String name) {
		return new DBNode(TYPE_NODE, name, false);
	}

	public DBNode(int nodeType, Object userObject, boolean allowsChildren) {
		super(userObject, allowsChildren);
		this.nodeType = nodeType;
	}

	public int getNodeType() {
		return this.nodeType;
	}
}
